"""
test.py; 验证脚本
"""

import pathlib as ptl
import sys

import torch
from icecream import ic

_cwd = ptl.Path(__file__).parent
_build_dir = _cwd / "build/lib.win-amd64-cpython-312"
_my_layer = _build_dir / "my_layer.pyd"
"""
sys.path.insert(0, _build_dir.as_posix())
ic(sys.path)
import my_layer
lin = my_layer.MyLinear(128, 64).cuda()
"""

"""
import torch
torch.ops.load_library(_my_layer.as_posix())
torch.classes.load_library(_my_layer.as_posix())
lin = torch.classes.my_layer.MyLinear(128, 64).cuda()
"""

"""
sys.path.insert(0, _build_dir.as_posix())
ic(sys.path)
import my_layer

ic(dir(my_layer))
ic(dir(my_layer.MyLinear))

lin = my_layer.MyLinear(128, 64)
ic(dir(lin))
lin = lin.cuda()

x = torch.randn(128, device="cuda")
y = lin.forward(x)
print(y.shape)  # torch.Size([64])
"""

sys.path.insert(0, _build_dir.as_posix())
ic(sys.path)
import my_layer

ic(dir(my_layer))
ic(dir(my_layer.MyLinear))

lin = my_layer.MyLinear(128, 64)
ic(dir(lin))
lin = lin.to()

x = torch.randn(128, device="cuda")
y = lin.forward(x)
print(y.shape)  # torch.Size([64])

